package factory;

import java.util.Map;

import module.ServiceModule;

import com.google.inject.Guice;
import com.google.inject.Injector;

public class ServiceFactory {
	
	//private static Map<String, Object> cache;
	private static Injector injector;
	
	static {
		//cache = Collections.emptyMap();
		injector = Guice.createInjector(new ServiceModule()); 
	}
	
	@SuppressWarnings("unchecked")
	public static <T> T getService(Class<T> serviceClass) {
		/*if(!cache.containsKey(serviceClass.getName())) {
			Object serviceImpl = injector.getInstance(serviceClass);
			cache.put(serviceClass.getName(), serviceImpl);
		}*/
		Object serviceImpl = injector.getInstance(serviceClass);
		return (T) serviceImpl; //cache.get(serviceClass.getName());
	}
}
